﻿using delete.models;
using Prism.Mvvm;
using Prism.Regions;
using System.Collections.ObjectModel;
using FontAwesome.WPF;
using System.Reflection;
using Prism.Commands;
using delete.Views;
using Prism.Services.Dialogs;
using delete.Common.UserControls;

namespace delete.ViewModels
{
    public class MainWindowViewModel : BindableBase
    {
        public MainWindowViewModel(IRegionManager region)
        {
            Region = region;
            CreateMenu();
        }
        public ObservableCollection<MenuButton> MenuButtons { get; set; }
        //导航命令
        private DelegateCommand<MenuButton> _navigationCommand;
        public DelegateCommand<MenuButton> NavigationCommand =>
            _navigationCommand ?? (_navigationCommand = new DelegateCommand<MenuButton>(ExecuteNavigationCommand));
        
        public IRegionManager Region { get; }

        void ExecuteNavigationCommand(MenuButton obj)
        {
            if (obj.ViewName !=null)
            {
                Region.RequestNavigate("ContentRegion", obj.ViewName);
            }
        }
        public void CreateMenu()
        {
            MenuButtons = new ObservableCollection<MenuButton>();
            MenuButtons.Add(new MenuButton { Icon = FontAwesomeIcon.Github,Title = "页面A",ViewName="ViewA" });
            MenuButtons.Add(new MenuButton { Icon = FontAwesomeIcon.Apple,Title = "页面B" , ViewName = "ViewB" });
            MenuButtons.Add(new MenuButton { Icon = FontAwesomeIcon.Android,Title = "页面C" ,ViewName = "ViewC" });
            MenuButtons.Add(new MenuButton { Icon = FontAwesomeIcon.Edge,Title = "页面D", ViewName = "ViewD" });
            MenuButtons.Add(new MenuButton { Icon = FontAwesomeIcon.Chrome,Title = "页面E", ViewName = "ViewE" });
        }
        
    }
}
